package com;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jumaojiang.constant.AppConfig;
import com.jumaojiang.exceptions.ResourceException;
import com.jumaojiang.mapper.ResourceGetTimeMapper;
import com.jumaojiang.mapper.RsVideoMapper;
import com.jumaojiang.pojo.ResourceGetTime;
import com.jumaojiang.pojo.ResourceGetTimeExample;
import com.jumaojiang.pojo.RsVideo;
import com.jumaojiang.pojo.RsVideoExample;
import com.jumaojiang.service.ParsingResourcesService;
import com.jumaojiang.service.ResourceService;
import com.jumaojiang.vo.AjaxResultVo;
import com.jumaojiang.wxpusher.bean.callback.CallBackData;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import static java.util.Calendar.*;

/**
 * javaee-rs
 *
 * @author wuhanwei
 * @version 1.0
 * @date 2021/11/8
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class UpdateFile {

    @Resource
    private RsVideoMapper rsVideoMapper;

    @Resource
    private AppConfig appConfig;

    @Resource
    private ParsingResourcesService service;

    @Test
    public void Mytest() throws Exception {
        String cookie = "gr_user_id=be8ddee6-500a-4983-a149-3d7fc7e3b05f; sensorsdata2015jssdkcross={\"distinct_id\":\"17d6a51855f8aa-06d1a5663075fe-978183a-1327104-17d6a51856062c\",\"first_id\":\"\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"17d6a51855f8aa-06d1a5663075fe-978183a-1327104-17d6a51856062c\"}; kd_user_id=4aa6c9d8-563f-4d0d-8fbd-d0b490fdde86; 99f53b614ce96c83_gr_session_id=e2bb06d4-5288-4d66-9e4b-1d0ed8ee602f; 99f53b614ce96c83_gr_session_id_e2bb06d4-5288-4d66-9e4b-1d0ed8ee602f=true; kd_5d6526d7-3c9f-460b-b6cf-ba75397ce1ac_log_id=blTQ8rhlEX7FWjHjtnV:ea51a2db-fb76-4901-bc85-cb2a4f474c52:62cae742-e5d5-4f02-99ff-40e17cff5919; sso_token=4edb622fd312027328d184ff573de85c; ssoToken=4edb622fd312027328d184ff573de85c; figui=oePAg94zCGO55134; access-edu_online=b2868dcc479f1136116401272c322066; kd_5d6526d7-3c9f-460b-b6cf-ba75397ce1ac_view_log_id=eDGomXaU8WyF6XLo2xf; kkb_edu_session=eyJpdiI6Im5CbnBDek1rXC9IbG8rdVhSUDBrd1FRPT0iLCJ2YWx1ZSI6IlwvU1wvVzROS2JaOUxYZjhpVWFzbkdEK1A1MmpoZGlURXZqUVlLXC9TS1p4cUFZbjVPZk9HSzBxXC81Z25Ba1lMS0pHIiwibWFjIjoiMDc4MWNiMDVhZjg5ZTE3NmU3YzQwMzgyMzUwZDU4N2Q3MjhkMGExYjMwNzgxMWI1YzA2OTEyMTYxMTZiZGZlOCJ9; kd_5d6526d7-3c9f-460b-b6cf-ba75397ce1ac_kuickDeal_pageIndex=0; kd_5d6526d7-3c9f-460b-b6cf-ba75397ce1ac_kuickDeal_leaveTime=1638381711988";
        for(int i=1; i<=17; i++){
            // 请求获取所有章节信息 & 获取指定章节的id
            String chapterId = service.parseChapterId(cookie, i);
            // 请求单章节信息 & 解析章节信息
            List<List<Object>> lists = service.parseChapterMsg(chapterId, cookie, i);
            // 更新数据库
            service.updateDB(lists);
        }
        System.out.println("ok");
    }
}















